package exam.db.dao;

import java.util.List;

import exam.driver.jdbc.JdbcManagerDao;

public class AbstractDao<T> extends JdbcManagerDao<T>{
	/**
	 * entityClass:Class
	 */
	private Class<T> entityClass;
	
	/**
	 * constructor
	 * @param entity
	 */
	public AbstractDao(Class<T> entity) {
		this.entityClass = entity;
	}
	/**
	 * selectBySqlFile
	 * @param file
	 * @param params
	 * @return
	 */
	public List<T> selectBySqlFile(String file, Object params) {
		return null;
	}
	
	/**
	 * selectAll:AbstractDao
	 * @param <E>
	 * @param entityName
	 * @param statement
	 * @return List<T>
	 */
	public <E> List<T> selectAll(Class<E> entityName, String statement) {
		return super.select(this.entityClass, entityName, statement).getListResult();
	}
	/**
	 * selectByPk:AbstractDao
	 * @param <E>
	 * @param entityName
	 * @param statement
	 * @return
	 */
	public <E> T selectByPk(Class<E> entityName, String statement) {
		return super.select(this.entityClass, entityName, statement).getSingleResult();
	}
	/**
	 * deleteByPk:AbstractDao
	 * @param statement
	 * @param arrayPk
	 * @return List<Integer>
	 */
	public List<Integer> deleteByPk(String statement, int[] arrayPk) {
		return super.delete(statement, arrayPk);
	}
	
	/**
	 * insertBySqlFile:AbstractDao
	 * @param entity
	 * @param sqlFile
	 * @return
	 */
	public int insertBySqlFile(T entity, String sqlFile) {
		return super.insert(entity, sqlFile);
	}
	
	/**
	 * updateBySqlFile:AbstractDao
	 * @param sqlFile
	 * @param params
	 * @return int
	 */
	public int updateBySqlFile(String sqlFile, List<Object> params) {
		return super.update(sqlFile, params);
	}
}
